<template>
  <view class="app-container">
    <!-- 搜索栏 -->
    <view class="search-section">
      <view class="search-row">
        <view class="search-item">
          <input class="input" v-model="queryParams.remarks" placeholder="请输入名称搜索" @confirm="handleQuery" />
        </view>
        
        <view class="search-item">
          <button class="btn-search" @click="handleQuery">搜索</button>
        </view>
        
        <view class="search-item">
          <button class="btn-add" @click="handleAdd">新增</button>
        </view>
      </view>
    </view>

         <!-- 服务器列表 -->
     <view class="list-container">
       <view v-for="(item, index) in serverList" :key="item.id" class="list-item">
         <uni-swipe-action>
           <uni-swipe-action-item :right-options="swipeOptions" @click="handleSwipeClick($event, item)">
             <view class="item-content-wrapper" @click="handleItemClick(item)">
               <view class="item-header">
                 <view class="item-title">{{item.remarks}}</view>
                 <view class="item-project">{{item.classificationName || '未分类'}}</view>
               </view>
               
               <view class="item-content">
                 <view class="info-row">
                   <text class="info-label">账号：</text>
                   <text class="info-value">{{item.username}}</text>
                   <button class="btn-copy" @click.stop="copyText(item.username)">复制</button>
                 </view>
                 
                 <view class="info-row">
                   <text class="info-label">密码：</text>
                   <text class="info-value">{{item.password}}</text>
                   <button class="btn-copy" @click.stop="copyText(item.password)">复制</button>
                 </view>
                 
                 <view class="info-row">
                   <text class="info-label">IP地址：</text>
                   <text class="info-value">{{item.website}}</text>
                   <button class="btn-copy" @click.stop="copyText(item.website)">复制</button>
                 </view>
                 
                 <view class="info-row">
                   <text class="info-label">服务类型：</text>
                   <text class="info-value">{{getFormDatatypeLabel(item.datatype) || '未设置'}}</text>
                 </view>
                 
                 <view class="info-row">
                   <text class="info-label">网络类型：</text>
                   <text class="info-value">{{getFormWllxLabel(item.wllx) || '未设置'}}</text>
                 </view>
               </view>
             </view>
           </uni-swipe-action-item>
         </uni-swipe-action>
       </view>
       
       <!-- 无数据提示 -->
       <view class="empty-state" v-if="!loading && serverList.length === 0">
         <view class="empty-text">暂无服务器数据</view>
       </view>
       

     </view>

     <!-- 详情弹窗 -->
     <uni-popup ref="detailPopup" type="center" :mask-click="true">
       <view class="detail-container">
         <view class="detail-header">
           <text class="detail-title">{{detailItem.remarks}}</text>
           <text class="detail-close" @click="closeDetail">×</text>
         </view>
         
         <view class="detail-content">
           <view class="detail-section">
             <view class="detail-item">
               <view class="detail-info">
                 <text class="detail-label">账号</text>
                 <text class="detail-value">{{detailItem.username}}</text>
               </view>
             </view>
             
             <view class="detail-item">
               <view class="detail-info">
                 <text class="detail-label">密码</text>
                 <text class="detail-value">{{detailItem.password}}</text>
               </view>
             </view>
             
             <view class="detail-item">
               <view class="detail-info">
                 <text class="detail-label">IP地址</text>
                 <text class="detail-value">{{detailItem.website}}</text>
               </view>
             </view>
             
             <view class="detail-item">
               <view class="detail-info">
                 <text class="detail-label">项目</text>
                 <text class="detail-value">{{detailItem.classificationName || '未分类'}}</text>
               </view>
             </view>
             
             <view class="detail-item">
               <view class="detail-info">
                 <text class="detail-label">服务类型</text>
                 <text class="detail-value">{{getFormDatatypeLabel(detailItem.datatype) || '未设置'}}</text>
               </view>
             </view>
             
             <view class="detail-item">
               <view class="detail-info">
                 <text class="detail-label">网络类型</text>
                 <text class="detail-value">{{getFormWllxLabel(detailItem.wllx) || '未设置'}}</text>
               </view>
             </view>
           </view>
         </view>
         
         <view class="detail-footer">
           <button class="detail-btn detail-btn-copy" @click="copyAllInfo">一键复制所有</button>
           <button class="detail-btn detail-btn-primary" @click="closeDetail">关闭</button>
         </view>
       </view>
     </uni-popup>

     <!-- 新增/修改弹窗 -->
     <uni-popup ref="formPopup" type="center" :mask-click="true">
       <view class="form-container">
         <view class="form-header">
           <text class="form-title">{{title}}</text>
           <text class="form-close" @click="closeForm">×</text>
         </view>
         
         <view class="form-content">
           <view class="form-section">
             <view class="form-item">
               <view class="form-info">
                 <text class="form-label">名称</text>
                 <input class="form-input" v-model="form.remarks" placeholder="请输入服务器名称" />
               </view>
             </view>
             
             <view class="form-item form-item-row">
               <view class="form-info">
                 <view class="form-field">
                   <text class="form-label">账号</text>
                   <input class="form-input" v-model="form.username" placeholder="请输入账号" />
                 </view>
                 
                 <view class="form-field">
                   <text class="form-label">密码</text>
                   <input class="form-input" v-model="form.password" placeholder="请输入密码" />
                 </view>
               </view>
             </view>
             
             <view class="form-item">
               <view class="form-info">
                 <text class="form-label">IP地址</text>
                 <input class="form-input" v-model="form.website" placeholder="请输入IP地址" />
               </view>
             </view>
             
             <view class="form-item form-item-row">
               <view class="form-info">
                 <view class="form-field">
                   <text class="form-label">服务类型</text>
                   <picker v-if="isDictDataReady" class="form-picker" :value="getFormDatatypeIndex(form.datatype)" :range="fwqlbOptions" range-key="label" @change="onFormDatatypeChange">
                     <view class="form-picker-text">{{getFormDatatypeLabel(form.datatype) || '请选择服务类型'}}</view>
                   </picker>
                   <view v-else class="form-picker form-picker-loading">
                     <view class="form-picker-text">加载中...</view>
                   </view>
                 </view>
                 
                 <view class="form-field">
                   <text class="form-label">网络类型</text>
                   <picker v-if="isDictDataReady" class="form-picker" :value="getFormWllxIndex(form.wllx)" :range="wllxOptions" range-key="label" @change="onFormWllxChange">
                     <view class="form-picker-text">{{getFormWllxLabel(form.wllx) || '请选择网络类型'}}</view>
                   </picker>
                   <view v-else class="form-picker form-picker-loading">
                     <view class="form-picker-text">加载中...</view>
                   </view>
                 </view>
               </view>
             </view>
             
             <view class="form-item">
               <view class="form-info">
                 <text class="form-label">备注</text>
                 <textarea class="form-textarea" v-model="form.remark" placeholder="请输入备注信息" />
               </view>
             </view>
           </view>
         </view>
         
         <view class="form-footer">
           <button class="form-btn form-btn-cancel" @click="closeForm">取消</button>
           <button class="form-btn form-btn-submit" @click="submitForm">确定</button>
         </view>
       </view>
     </uni-popup>
  </view>
</template>

<script>
import { listServer, getServer, addServer, delServer, updateServer } from '../../api/server';
import { getDictData } from '../../utils/dictUtils';

export default {
  onPullDownRefresh: true,
  data() {
    return {
      loading: true,
      serverList: [],
      currentProject: {},
      title: '',
      queryParams: {
        pageNum: 1,
        pageSize: 100000,
        remarks: '',
        classificationId: ''
      },
      form: {},
      swipeOptions: [
        { text: '修改', style: { backgroundColor: '#007aff' } },
        { text: '删除', style: { backgroundColor: '#ff3b30' } }
      ],
      detailItem: {},
      fwqlbOptions: [],
      wllxOptions: []

    };
  },
  
  computed: {
    // 检查字典数据是否已加载
    isDictDataReady() {
      return this.fwqlbOptions.length > 0 && this.wllxOptions.length > 0;
    }
  },
  
  watch: {
    // 监听字典数据变化，当数据加载完成后，如果表单有值则重新计算标签
    isDictDataReady(newVal) {
      if (newVal && this.form.id) {
        // 字典数据加载完成，表单可以正常显示
      }
    }
  },
  
  onLoad() {
    this.getGlobalProject();
    this.getDictOptions();
    this.getList();
  },
  
  onPullDownRefresh() {
    // 下拉刷新
    this.onRefresh();
  },
  methods: {

    // 获取字典选项
    async getDictOptions() {
      try {
        
        // 获取服务类型字典
        const fwqlbData = await getDictData('fwqlb', false);
        this.fwqlbOptions = fwqlbData || [];
        
        // 获取网络类型字典
        const wllxData = await getDictData('wllx', false);
        this.wllxOptions = wllxData || [];
        
      } catch (error) {
        console.error('获取字典数据失败:', error);
        // 如果获取失败，设置默认选项
        this.fwqlbOptions = [];
        this.wllxOptions = [];
      }
    },
    
    getGlobalProject() {
      const storedProject = uni.getStorageSync('currentProject');
      if (storedProject && storedProject.id) {
        this.currentProject = storedProject;
        if (storedProject.id !== 'all') {
          this.queryParams.classificationId = storedProject.id;
          this.form.classificationId = storedProject.id;
        }
      }
    },
    
    getList() {
      this.loading = true;
      return listServer(this.queryParams).then(res => {
        if (res.code === 200) {
          // 直接替换数据，一次性加载所有
          this.serverList = res.rows || [];
          
        }
        this.loading = false;
        return res;
      }).catch((error) => {
        console.error('获取服务器列表失败:', error);
        this.loading = false;
        throw error;
      });
    },
    
    handleQuery() {
      this.serverList = [];
      this.getList();
    },
    
         handleAdd() {
       this.resetForm();
       this.title = '添加服务器';
       this.$refs.formPopup.open();
     },
     
     handleUpdate(row) {
       getServer(row.id).then(res => {
         if (res.code === 200) {
           this.form = res.data;
           
           // 确保字典数据已加载
           if (this.isDictDataReady) {
             this.title = '修改服务器';
             this.$refs.formPopup.open();
           } else {
             // 等待字典数据加载完成后再打开弹窗
             this.$nextTick(() => {
               if (this.isDictDataReady) {
                 this.title = '修改服务器';
                 this.$refs.formPopup.open();
               } else {
                 setTimeout(() => {
                   this.title = '修改服务器';
                   this.$refs.formPopup.open();
                 }, 500);
               }
             });
           }
         }
       });
     },
    
         handleSwipeClick(event, item) {
       if (event.index === 0) {
         // 修改
         this.handleUpdate(item);
       } else if (event.index === 1) {
         // 删除
         this.handleDelete(item);
       }
     },
    
    handleDelete(row) {
      const ids = row ? [row.id] : [];
      uni.showModal({
        title: '提示',
        content: `是否确认删除选中的${ids.length}条数据？`,
        success: res => {
          if (res.confirm) {
            delServer(ids).then(() => {
              uni.showToast({ title: '删除成功', icon: 'success' });
              this.getList();
            });
          }
        }
      });
    },
    
    copyText(text) {
      uni.setClipboardData({
        data: text,
        success: () => {
          uni.showToast({ title: '复制成功', icon: 'success' });
        }
      });
    },
    
    resetForm() {
      this.form = {
        id: null,
        remarks: '',
        username: '',
        password: '',
        website: '',
        yuming: '',
        classificationId: this.currentProject.id !== 'all' ? this.currentProject.id : '',
        remark: '',
        datatype: '', // 服务类型 - 改为空字符串，参考数据库页面
        wllx: '' // 网络类型 - 改为空字符串，参考数据库页面
      };
    },
    
    onRefresh() {
      this.serverList = [];
      this.getList().then(() => {
        // 数据加载完成后停止下拉刷新动画
        uni.stopPullDownRefresh();
      }).catch(() => {
        // 即使出错也要停止下拉刷新动画
        uni.stopPullDownRefresh();
      });
    },
    

    
         handleItemClick(item) {
       // 显示详情
       this.showDetail(item);
     },
     
     showDetail(item) {
       this.detailItem = item;
       this.$refs.detailPopup.open();
     },
     
     closeDetail() {
       this.$refs.detailPopup.close();
     },
     
           copyAllInfo() {
       const allInfo = `名称：${this.detailItem.remarks}
账号：${this.detailItem.username}
密码：${this.detailItem.password}
IP地址：${this.detailItem.website}
项目：${this.detailItem.classificationName || '未分类'}
服务类型：${this.getFormDatatypeLabel(this.detailItem.datatype) || '未设置'}
网络类型：${this.getFormWllxLabel(this.detailItem.wllx) || '未设置'}`;
       
       uni.setClipboardData({
         data: allInfo,
         success: () => {
           uni.showToast({ title: '所有信息已复制', icon: 'success' });
         }
       });
     },
     
     // 关闭表单弹窗
     closeForm() {
       this.$refs.formPopup.close();
       this.resetForm();
     },
     
     // 提交表单
     submitForm() {
       // 表单验证
       if (!this.form.remarks || !this.form.username || !this.form.password || !this.form.website || !this.form.datatype || !this.form.wllx) {
         uni.showToast({
           title: '请填写完整信息',
           icon: 'none'
         });
         return;
       }
       
       // 设置项目分类ID - 必须选择一个具体项目
       if (!this.currentProject.id || this.currentProject.id === 'all') {
         uni.showToast({
           title: '请先选择一个具体的项目分类',
           icon: 'none'
         });
         return;
       }
       
       this.form.classificationId = this.currentProject.id;
       
       if (this.form.id) {
         // 修改
         updateServer(this.form).then(res => {
           if (res.code === 200) {
             uni.showToast({ title: '修改成功', icon: 'success' });
             this.closeForm();
             this.getList();
           }
         });
       } else {
         // 新增
         addServer(this.form).then(res => {
           if (res.code === 200) {
             uni.showToast({ title: '添加成功', icon: 'success' });
             this.closeForm();
             this.getList();
           }
         });
       }
           },

    // 服务类型选择变化 (表单)
    onFormDatatypeChange(e) {
      const index = e.detail.value;
      this.form.datatype = this.fwqlbOptions[index].value;
    },

    // 网络类型选择变化 (表单)
    onFormWllxChange(e) {
      const index = e.detail.value;
      this.form.wllx = this.wllxOptions[index].value;
    },

    // 获取服务类型标签 (表单)
    getFormDatatypeLabel(value) {
      
      if (!value || !this.fwqlbOptions || this.fwqlbOptions.length === 0) {
        return '';
      }
      
      const option = this.fwqlbOptions.find(item => item.value == value);
      return option ? option.label : '';
    },

    // 获取网络类型标签 (表单)
    getFormWllxLabel(value) {
      
      if (!value || !this.wllxOptions || this.wllxOptions.length === 0) {
        return '';
      }
      
      const option = this.wllxOptions.find(item => item.value == value);
      return option ? option.label : '';
    },

    // 获取服务类型索引 (表单)
    getFormDatatypeIndex(value) {
      
      if (!this.fwqlbOptions || this.fwqlbOptions.length === 0) {
        return 0;
      }
      
      if (!value) {
        return 0;
      }
      
      const index = this.fwqlbOptions.findIndex(item => item.value == value);
      return index >= 0 ? index : 0;
    },

    // 获取网络类型索引 (表单)
    getFormWllxIndex(value) {
      
      if (!this.wllxOptions || this.wllxOptions.length === 0) {
        return 0;
      }
      
      if (!value) {
        return 0;
      }
      
      const index = this.wllxOptions.findIndex(item => item.value == value);
      return index >= 0 ? index : 0;
    }

   }
};
</script>

<style scoped>
.app-container {
  padding: 20rpx;
  background-color: #f5f5f5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.search-section {
  background-color: #fff;
  border-radius: 16rpx;
  padding: 0;
  margin-bottom: 20rpx;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.search-row {
  display: flex;
  align-items: center;
  background-color: #f8f9fa;
  border: 2rpx solid #e9ecef;
  border-radius: 16rpx;
}

.search-item {
  display: flex;
  align-items: center;
  flex: 1;
  border-right: 1rpx solid #e9ecef;
}

.search-item:last-child {
  flex: none;
  width: auto;
  border-right: none;
}

.search-item:nth-child(1) {
  flex: 1;
  min-width: 200rpx;
}

.search-item:nth-child(2),
.search-item:nth-child(3) {
  flex: none;
  width: auto;
}

.search-item:nth-child(4),
.search-item:nth-child(5),
.search-item:nth-child(6) {
  flex: none;
  width: 100rpx;
}

.input {
  flex: 1;
  height: 70rpx;
  background-color: transparent;
  border: none;
  border-radius: 0;
  padding: 0 20rpx;
  font-size: 28rpx;
  color: #333;
}

.btn-search {
  height: 70rpx;
  padding: 0 20rpx;
  font-size: 28rpx;
  line-height: 70rpx;
  border-radius: 0;
  border: none;
  background-color: #007aff;
  color: #fff;
  font-weight: 500;
}



.btn-add {
  height: 70rpx;
  padding: 0 20rpx;
  font-size: 28rpx;
  line-height: 70rpx;
  border-radius: 0;
  border: none;
  background-color: #4cd964;
  color: #fff;
  font-weight: 500;
}

.picker {
  flex: 1;
  height: 70rpx;
  background-color: #f8f9fa;
  border: 2rpx solid #e9ecef;
  border-radius: 8rpx;
  padding: 0 20rpx;
  font-size: 28rpx;
  color: #333;
  display: flex;
  align-items: center;
}

.picker-text {
  font-size: 28rpx;
  color: #333;
}

.list-container {
  background-color: #fff;
  border-radius: 16rpx;
  overflow: hidden;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
  margin-bottom: 20rpx;
  height: calc(100vh - 200rpx);
  flex: 1;
}

.list-item {
  padding: 0;
  border-bottom: none;
}

.item-content-wrapper {
  background-color: #fff;
  padding: 30rpx;
  border-bottom: 1rpx solid #f0f0f0;
}

.list-item:last-child .item-content-wrapper {
  border-bottom: none;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20rpx;
}

.item-title {
  font-size: 34rpx;
  font-weight: 600;
  color: #333;
  flex: 1;
  margin-right: 20rpx;
}

.item-project {
  font-size: 24rpx;
  color: #666;
  background-color: #f0f0f0;
  padding: 8rpx 16rpx;
  border-radius: 20rpx;
}

.item-content {
  margin-bottom: 20rpx;
}

.info-row {
  display: flex;
  align-items: center;
  margin-bottom: 15rpx;
}

.info-label {
  font-size: 28rpx;
  color: #666;
  margin-right: 15rpx;
  white-space: nowrap;
}

.info-value {
  font-size: 28rpx;
  color: #333;
  flex: 1;
  margin-right: 15rpx;
}

.btn-copy {
  font-size: 24rpx;
  color: #007aff;
  background: none;
  border: none;
  padding: 5rpx 10rpx;
  border-radius: 8rpx;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 100rpx 30rpx;
  text-align: center;
  min-height: 400rpx;
}

 .empty-text {
   font-size: 32rpx;
   color: #666;
   font-weight: 500;
 }

.load-more {
  padding: 30rpx;
  text-align: center;
  background-color: #fff;
}

.loading-text,
.no-more-text,
.load-more-text {
  font-size: 28rpx;
  color: #999;
}

.loading-text {
  color: #007aff;
}

.no-more-text {
  color: #ccc;
}

.detail-container {
  width: 90vw;
  max-width: 600rpx;
  background-color: #fff;
  border-radius: 20rpx;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30rpx;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 30rpx;
  padding-bottom: 20rpx;
  border-bottom: 1rpx solid #e9ecef;
}

.detail-title {
  font-size: 36rpx;
  font-weight: 600;
  color: #333;
  flex: 1;
  text-align: center;
}

.detail-close {
  font-size: 48rpx;
  color: #999;
  padding: 0 20rpx;
  line-height: 100rpx;
}

.detail-content {
  width: 100%;
  margin-bottom: 30rpx;
  padding-bottom: 20rpx;
  border-bottom: 1rpx solid #e9ecef;
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
  margin-bottom: 20rpx;
  padding-bottom: 20rpx;
  border-bottom: 1rpx dashed #eee;
}

.detail-item {
  display: flex;
  align-items: center;
  padding: 20rpx 0;
  border-bottom: 1rpx solid #f0f0f0;
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 20rpx;
}

.detail-label {
  font-size: 28rpx;
  color: #666;
  white-space: nowrap;
  min-width: 120rpx;
}

.detail-value {
  font-size: 28rpx;
  color: #333;
  flex: 1;
  word-break: break-all;
}

.detail-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-top: 20rpx;
  border-top: 1rpx solid #e9ecef;
}

.detail-btn {
  min-width: 160rpx;
  height: 80rpx;
  line-height: 80rpx;
  font-size: 30rpx;
  font-weight: 500;
  border-radius: 12rpx;
  border: none;
}

.detail-btn-copy {
  background-color: #4cd964;
  color: #fff;
  margin-right: 20rpx;
}

.detail-btn-primary {
  background-color: #007aff;
  color: #fff;
}

/* 表单弹窗样式 */
.form-container {
  width: 90vw;
  max-width: 750rpx;
  background-color: #fff;
  border-radius: 20rpx;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30rpx;
  box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.1);
}

.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 30rpx;
  padding-bottom: 20rpx;
  border-bottom: 1rpx solid #e9ecef;
}

.form-title {
  font-size: 36rpx;
  font-weight: 600;
  color: #333;
  flex: 1;
  text-align: center;
}

.form-close {
  font-size: 48rpx;
  color: #999;
  padding: 0 20rpx;
  line-height: 100rpx;
  cursor: pointer;
}

.form-content {
  width: 100%;
  margin-bottom: 30rpx;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
  margin-bottom: 20rpx;
  padding-bottom: 20rpx;
  border-bottom: 1rpx dashed #eee;
}

.form-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.form-item {
  display: flex;
  align-items: center;
  padding: 20rpx 0;
  border-bottom: 1rpx solid #f0f0f0;
}

.form-item:last-child {
  border-bottom: none;
}

.form-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10rpx;
}

.form-item-row {
  display: flex;
  justify-content: space-between;
  gap: 20rpx;
}

.form-item-row .form-info {
  flex-direction: row;
  gap: 30rpx;
  width: 100%;
}

.form-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10rpx;
}

.form-field .form-label {
  margin-bottom: 5rpx;
}

.form-field .form-input,
.form-field .form-picker {
  width: 100%;
}

.form-label {
  font-size: 28rpx;
  color: #666;
  white-space: nowrap;
  min-width: 120rpx;
  margin-bottom: 8rpx;
}

.form-input {
  flex: 1;
  height: 70rpx;
  background-color: #f8f9fa;
  border: 2rpx solid #e9ecef;
  border-radius: 12rpx;
  padding: 0 20rpx;
  font-size: 28rpx;
  color: #333;
  transition: all 0.3s ease;
}

.form-input:focus {
  border-color: #007aff;
  background-color: #fff;
  box-shadow: 0 0 0 3rpx rgba(0, 122, 255, 0.1);
}

.form-picker {
  flex: 1;
  height: 70rpx;
  background-color: #f8f9fa;
  border: 2rpx solid #e9ecef;
  border-radius: 12rpx;
  padding: 0 20rpx;
  font-size: 28rpx;
  color: #333;
  display: flex;
  align-items: center;
  transition: all 0.3s ease;
}

.form-picker:active {
  border-color: #007aff;
  background-color: #fff;
}

.form-picker-text {
  font-size: 28rpx;
  color: #333;
}

.form-picker-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 70rpx;
  background-color: #f8f9fa;
  border: 2rpx solid #e9ecef;
  border-radius: 12rpx;
  padding: 0 20rpx;
  font-size: 28rpx;
  color: #999;
  cursor: not-allowed;
}

.form-picker-loading .form-picker-text {
  color: #999;
  font-style: italic;
}

.form-textarea {
  flex: 1;
  min-height: 100rpx;
  background-color: #f8f9fa;
  border: 2rpx solid #e9ecef;
  border-radius: 12rpx;
  padding: 20rpx;
  font-size: 28rpx;
  color: #333;
  resize: none;
  transition: all 0.3s ease;
}

.form-textarea:focus {
  border-color: #007aff;
  background-color: #fff;
  box-shadow: 0 0 0 3rpx rgba(0, 122, 255, 0.1);
}

.form-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 30rpx;
  padding-top: 30rpx;
  border-top: 1rpx solid #e9ecef;
}

.form-btn {
  min-width: 160rpx;
  height: 80rpx;
  line-height: 80rpx;
  font-size: 30rpx;
  font-weight: 500;
  border-radius: 12rpx;
  border: none;
  transition: all 0.3s ease;
}

.form-btn-cancel {
  background-color: #f0f0f0;
  color: #666;
}

.form-btn-cancel:active {
  background-color: #e0e0e0;
  transform: translateY(2rpx);
}

.form-btn-submit {
  background-color: #007aff;
  color: #fff;
}

.form-btn-submit:active {
  background-color: #0056b3;
  transform: translateY(2rpx);
}

/* 响应式设计 */
@media (max-width: 750rpx) {
  .form-container {
    width: 95vw;
    max-width: none;
    padding: 40rpx 30rpx;
  }
  
  .form-section {
    flex-direction: column;
    margin-bottom: 30rpx;
    gap: 20rpx;
  }
  
  .form-item {
    padding: 20rpx 0;
    border-bottom: 1rpx solid #f0f0f0;
  }
  
  .form-item:last-child {
    border-bottom: none;
  }
  
  .form-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 10rpx;
  }
  
  .form-item-row .form-info {
    flex-direction: column;
    gap: 20rpx;
  }
  
  .form-field {
    width: 100%;
  }
  
  .form-field .form-input,
  .form-field .form-picker {
    width: 100%;
  }
  
  .form-label {
    min-width: 120rpx;
    font-size: 28rpx;
    margin-bottom: 8rpx;
  }
  
  .form-input,
  .form-picker {
    height: 70rpx;
    font-size: 28rpx;
    width: 100%;
  }
  
  .form-textarea {
    min-height: 100rpx;
    font-size: 28rpx;
    width: 100%;
  }
  
  .form-btn {
    min-width: 160rpx;
    height: 80rpx;
    line-height: 80rpx;
    font-size: 30rpx;
  }
  
  .form-header {
    margin-bottom: 30rpx;
    padding-bottom: 20rpx;
  }
  
  .form-title {
    font-size: 36rpx;
  }
  
  .form-content {
    margin-bottom: 30rpx;
  }
  
  .form-footer {
    gap: 30rpx;
    padding-top: 30rpx;
  }
}
</style>
